<template>
	<view class="wp">
		<view class="list_item" v-for="(item,idx) in info" :key="item+idx">
			<view class="" style="display: flex;align-items: center;padding-bottom: 10upx;">
				<text>说明（{{idx-0+1}}）：</text><button size="mini" @click="deleteTap(idx)">删除</button>
			</view>
			<uni-easyinput :clearable="false" v-model="info[idx]" placeholder="折扣说明" />
		</view>
		<view class="btns">
			<button class="but_sub1" @click="addLaber">添加标签说明</button>
			<button class="but_sub2" @click="submitTap">提交标签说明</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid:'',
				info: [],
			}
		},
		onLoad(options) {
			this.uid=options.uid;
			this.getInfo();
		},
		methods: {
			getInfo() {
				this.$axios('info/getPayRemake', 'POST', 'supplier',{
					uid:this.uid
				}).then(res => {
					if (res.data.code == 200) {
						this.info = res.data.data;
					}
				})
			},
			submitTap() {
				let info = this.info.filter(v => {
					return v !== '';
				})
				this.$axios('info/setPayRemake', 'POST', 'supplier', {
					payremake: info,
					uid:this.uid
				}).then(res => {
					if (res.data.code == 200) {
						this.$api.msg('提交成功！');
					}
				})
			},
			deleteTap(v) {
				this.info.splice(v, 1);
			},
			addLaber() {
				this.info.push('');
			},
		}
	}
</script>

<style lang="scss">
	.wp {
		padding: 20upx;
	}

	.list_item {
		padding-bottom: 20upx;

		text {
			font-size: 32upx;
		}

		button {
			margin-left: 20upx;
		}
	}
	.btns{
		display: flex;
		justify-content: space-between;
	}
	.but_sub1,
	.but_sub2 {
		color: #fff;
		font-size: 32upx;
		line-height: 90upx;
		margin-top: 20upx;
		width: 47%;
		box-shadow: 4rpx 5rpx 17rpx 7rpx #ddd;
	}

	.but_sub1 {
		background: $btn-one;
	}

	.but_sub2 {
		background: $bg-color;
	}
</style>